<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>        
<script type="text/javascript">
   function deleteObject(id){
       if(confirm('Bạn chắc chắn muốn xóa ?')){
           var url = '${pageContext.request.contextPath}/company/delete/'+id;
           window.location.href = url;
       }
   }
</script>
<div class="sub-content">
	<jsp:include page="form-search.jsp"></jsp:include> 
	<c:if test="${url_01.add eq 1}">
		<a href="${pageContext.request.contextPath}/company/add">Thêm mới</a>   
	</c:if>	   
	<c:choose>
		<c:when test="${!empty objs}">
			<table class="tb-content">
				<tr>
				    <th>Tên đầy đủ</th>
				    <th>Địa chỉ</th>
				    <th>Điện thoại liện hệ</th>			    		
				    <th>Thành phố</th>		
				    <th>Email</th>    
				    <th>&nbsp;</th>
				</tr>
				<c:forEach items="${objs}" var="obj">
				    <tr>
				        <td>${obj.companyFullName} </td>
				        <td>${obj.companyAddress}</td>
				        <td>${obj.companyPhone}</td>
				        <td>${obj.cityId.cityName}</td>			        
				        <td>
				        	<c:choose>
					        	<c:when test="${url_01.edit eq 1}">
					        		 <a href="${pageContext.request.contextPath}/company/edit/${obj.companyId}">${obj.companyEmail}</a>
					        	</c:when>
					        	<c:otherwise>${obj.companyEmail}</c:otherwise>
					        </c:choose>	
				       
				        </td>
				        <td>
				        	<c:choose>
					        	<c:when test="${url_01.delete eq 1}">
					        		<a href="javascript: void(0)"  onclick="deleteObject(${obj.companyId})">Xóa</a>
					        	</c:when>
					        	<c:otherwise>-</c:otherwise>
					      	</c:choose>
				        </td>
				    </tr>
				</c:forEach>
			</table>
		</c:when>
		<c:otherwise><p class="tb-empty"><spring:message code="label.tb.empty"/></p></c:otherwise>
	</c:choose> 
</div>
 
